import type {AxiosResponse} from 'axios';
import axios, {InternalAxiosRequestConfig} from 'axios';
import {ApiResult} from "@/request/types/base";

const net = axios.create({
    baseURL: import.meta.env.VITE_API_URL as string
});

// 添加请求拦截器
net.interceptors.request.use(
    (config: InternalAxiosRequestConfig) => {
        return config
    },
    (error) => {
        return Promise.reject(error);
    }
);

// 添加响应拦截器
net.interceptors.response.use((result: AxiosResponse<ApiResult<unknown> | any>) => {
    return result.data
});


export { net };
